/* 
 * Fonctions AJAX
 */

function ajaxLoad(url, id, formId)
{
    if(!url) return false;
    if(!id) return false;
    
    var formData = $('#' + formId).serialize();
    var ajax = $.ajax({
        type: 'post',
        url : url,
        data: formData
    });
    ajax.success(function(data){
        $("#" + id).html(data);
    });
    ajax.error(function(){
        alert("Erreur de chargement de l'adresse " + url);
    });
}

function ajaxOpenDialog(url, width, height, title)
{
    if(!url) return false;
    if(!width) width = 256;
    if(!height) height = 256;
    if(!title) title = 'Edition';
    
    var ajax = $.ajax({
        type: 'get',
        url : url
    });
    ajax.success(function(data){
        $("#grh-dialog").html('').delay(100).html(data).dialog({
            width: width,
            height: height,
            modal: true,
            autoOpen: true,
            title: title
        });
    });
    ajax.error(function(){
        alert('Une erreur est survenue');
    });
}
